package com.platform.system.mqtt.utils;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.mqtt.MqttConnectMessage;
import io.netty.handler.codec.mqtt.MqttPublishMessage;
import io.netty.handler.codec.mqtt.MqttSubscribeMessage;
import io.netty.handler.codec.mqtt.MqttUnsubscribeMessage;

import java.util.List;

/**
 * @author Huangkai
 */
public interface MqttService {
    /**
     * 连接
     * @param ctx
     * @param msg
     */
    void processConnect(ChannelHandlerContext ctx, MqttConnectMessage msg);

    /**
     * 发布
     * @param ctx
     * @param msg
     */
    void processPublish(ChannelHandlerContext ctx, MqttPublishMessage msg);

    /**
     * 订阅
     * @param ctx
     * @param msg
     */
    void processSubscribe(ChannelHandlerContext ctx, MqttSubscribeMessage msg);

    /**
     * 取消订阅
     * @param ctx
     * @param msg
     */
    void processUnsubscribe(ChannelHandlerContext ctx, MqttUnsubscribeMessage msg);

    /**
     * 断开连接
     * @param ctx
     */
    void processDisconnect(ChannelHandlerContext ctx);

    /**
     * 心跳
     * @param ctx
     */
    void processPingReq(ChannelHandlerContext ctx);

    /**
     * 向客户端发布消息
     * @param message
     * @param clientIdList
     * @param topic
     */
    void publishToClient(List<String> clientIdList, String topic, String message);
}
